package com.baihan.angus.app.game.busshow.views;

import android.app.Activity;
import android.graphics.Rect;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

public class SpaceItemDecoration extends RecyclerView.ItemDecoration {

    private Activity mContext;
    private int space;  //位移间距
    private int mColumnCount;  //列数

    public SpaceItemDecoration(int space, Activity context, int columnCount) {
        this.space = space;
        this.mContext = context;
        this.mColumnCount = columnCount;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

        int position = parent.getChildAdapterPosition(view) % mColumnCount;
        outRect.left = position * (space / (mColumnCount - 1) - space / mColumnCount);

//        if (parent.getChildAdapterPosition(view) >= mColumnCount) {
//            outRect.top = ComUtil.Dp2Px(mContext, 10);
//        } else {
//            outRect.top = 0;
//        }
    }
}
